$ = function(name){
    var el = document.getElementById(name);
    if (typeof el == "array"){
        return el[0];
    }
    return el;
}
$P = function(name,parentType){
    var el;
    if (typeof name == "string"){
        el = $(name);
    }else{
        el = name;
    }
    if (el == null)return null;
    while(el != null){
        if (el.tagName.toLowerCase() == parentType)return el;
        el = el.parentNode;
    }
    return null;
}
$T = function(name){
	return document.getElementsByTagName(name);
}
function getElementPosition (elem) {
	var offsetTrail = elem;
	var offsetLeft = 0;
	var offsetTop = 0;
	
	while (offsetTrail) {
		offsetLeft += offsetTrail.offsetLeft;
		offsetTop += offsetTrail.offsetTop;
		offsetTrail = offsetTrail.offsetParent;
	}
	if ((navigator.userAgent.indexOf ("Mac") != -1) && (typeof document.body.leftMargin != "undefined")) {
		offsetLeft += document.body.leftMargin;
		offsetTop += document.body.topMargin;
	}

	return {left:offsetLeft, top:offsetTop};
}
